package com.kepler.aqs;

import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

import java.util.concurrent.locks.Lock;

public class Run {
    private static int m = 0;
    private static Lock mlock = new MLock();

    public static void main(String[] args) throws InterruptedException {
        Thread[] threads = new Thread[100];
        for(int i = 0; i < threads.length; i ++){
            threads[i] = new Thread(() -> {
               try{
                   mlock.lock();
                   for(int j = 0; j < 100; j ++){
                       m ++;
                   }
               }finally {
                   mlock.unlock();
               }
            });
        }
        for(Thread t : threads){
            t.start();
        }
        for (Thread t : threads){
            t.join();
        }
        System.out.println(m);
    }
}
